package demo2;


import java.util.Stack;

class TreeNode {
    public int val;
    public TreeNode left;
    public TreeNode right;
}
public class BinaryTree {
    public void preOrderNor (TreeNode root) {
        Stack<TreeNode> stack = new Stack<>();
        TreeNode cur = root;
        while (cur !=null || !stack.empty()) {
            while (cur != null) {
                stack.push(cur);
                System.out.println(cur.val + " ");
                cur = cur.left;
            }
            TreeNode top = stack.pop();
            cur = top.right;
        }

    }
}
